<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var res = '684'//限制输入255以内的数字
    var reg = /(^\d$)|(^[1-9]\d$)|(^1\d{2}$)|(^2[0-4]\d$)|(^25[0-5])/
    console.log(reg.test(res))
  </script>
</body>

</html>